<?php

include '../Config.php';

# objlib library code
include "{$objLibDir}/pdoExt.php";
include "{$objLibDir}/Util.php";
include "{$objLibDir}/Object.php";
include "{$objLibDir}/JoinerRelation.php";
include "{$objLibDir}/SortedJoinerRelation.php";
include "{$objLibDir}/KeyRelation.php";
include "{$objLibDir}/SortedKeyRelation.php";
include "{$objLibDir}/Query.php";
include "{$objLibDir}/Node.php";

# englopya library code
foreach (glob ("{$classesDir}/*.php") as $componentFile) {
        include_once ($componentFile);
}

foreach (glob ("{$classesDir}/Component/*.php") as $componentFile) {
        include_once ($componentFile);
}

# englopya Relations
foreach (glob ("{$classesDir}/Relations/*.php") as $includeFile) {
	include_once ($includeFile);
}

include "{$rootDir}/dbConn.php";

# create root nav for front-end
$rootNav = new Nav (false, false, array (
	'id' => $rootNavId,
	'title' => 'Home Page',
	'URL' => 'home',
	'style' => 'default_style.php',
	'template' => 'default_template.php',
	'editFormTemplate' => 'default_editFormTemplate.php'
));
$rootNav->save ();

# create administration home page ----------
$mainPage = new Page (false, array (
	'title' => 'Admin Dashboard',
	'style' => 'admin_dashboard.php',
	'template' => 'admin_dashboard.php',
	'editFormTemplate' => 'default_editFormTemplate.php'
));
$mainPage->save ();
$mainPage->assignComponent ($rootNav, 'Navigation Tree', 'admin_tree.php');

# article for settings menu ----------
$settingsMenu = new Article (false, array (
	'title' => 'Settings'
));
$settingsMenu->content = <<<MENU
<p><a href="/admin/index.php/adminAccount">Admin Account</a></p>
<p><a href="/admin/index.php/database">Database</a></p>
<p><a href="/admin/index.php/preferences">Site Preferences</a></p>
MENU;
$settingsMenu->save ();
$mainPage->assignComponent ($settingsMenu, 'Settings Menu');

# New Component Menu ------
$componentList = new Article (false, array (
	'title' => 'Component List',
	'template' => 'componentList.php'
));
$componentList->save ();
$mainPage->assignComponent ($componentList, 'Component List');

# Component picker ------
$componentPicker = new Article (false, array (
	'title' => 'Component Picker',
	'template' => 'componentPicker.php'
));
$componentPicker->save ();
$mainPage->assignComponent ($componentPicker, 'Component Picker');

# administration home navigation -----
$adminRootNav = new Nav (false, false, array (
    'id' => 'NAV00000000000000000000000000001',
	'title' => 'Home',
	'URL' => 'admin'
));
$adminRootNav->assignComponent ($mainPage);
$adminRootNav->save ();

# componentList_changeClass ajax action page
$changeClassPage = new Page (false, array(
	'title' => 'componentSelector_changeClass',
	'style' => 'componentSelector_changeClass.php'
));
$changeClassPage->save ();

$changeClassNav = new Nav (false, false, array (
	'title' => 'componentSelector_changeClass',
	'URL' => 'componentSelector_changeClass'
));
$changeClassNav->assignComponent ($changeClassPage);
$changeClassNav->save ();
$adminRootNav->assignChild ($changeClassNav);

# styleSelector_changeFolder ajax action page
$changeFolderPage = new Page (false, array(
	'title' => 'styleSelector_changeFolder',
	'style' => 'styleSelector_changeFolder.php'
));
$changeFolderPage->save ();

$changeFolderNav = new Nav (false, false, array (
	'title' => 'styleSelector_changeFolder',
	'URL' => 'styleSelector_changeFolder'
));
$changeFolderNav->assignComponent ($changeFolderPage);
$changeFolderNav->save();
$adminRootNav->assignChild ($changeFolderNav);

# componentPicker_updateList page
$updateListPage = new Page (false, array(
	'title' => 'componentPicker_updateList',
	'style' => 'componentPicker_updateList.php'
));
$updateListPage->save ();

$updateListNav = new Nav (false, false, array (
	'title' => 'componentPicker_updateList',
	'URL' => 'componentPicker_updateList'
));
$updateListNav->assignComponent ($updateListPage);
$updateListNav->save();
$adminRootNav->assignChild ($updateListNav);
?>